{extend name="$BASE_LIST" /}
{block name="body"}
<div class="right-main">
    <div class="page_nav" id="js_page_nav"><span class="page_title">{$page_nav}</span></div>
    <div id="js_main_header" class="ui-form main_header">
        <span class="frm_input_box search append">
            <a href="javascript:void(0);" id="js_search" class="frm_input_append">
                <i class="icon wb-search" title="搜索"></i>
            </a>
            <input type="text" id="js_keyword" placeholder="请输入用户名\手机号" value="" class="frm_input"/>
        </span>
      <!--   <span class="right">       
            
            <button type="button" id="js_addBtn" class="btn btn-primary"><i class="icon wb-plus"></i>添加罩杯</button>
            
        </span> -->

    </div>
    <table id="grid-table">
        <thead frozen="true">
        <th data-options="field:'username',width:150,align:'center',sortable: true">用户</th>
        <th data-options="field:'phone',width:150,align:'center',sortable: true">手机号</th>
        </thead>
        <thead>
            <tr>
                <th data-options="field:'content',width:500,align:'center'">反馈内容</th>
<!--                <th data-options="field:'images',width:160,align:'center',formatter:formatImg">反馈图片</th>-->
                <th data-options="field:'create_time',width:150,align:'center'">反馈时间</th>
                <th data-options="field:'reply_content',width:250,align:'center'">客服回复</th>
                <th data-options="field:'update_time',width:160,align:'center'">回复时间</th>
                <th data-options="field:'is_reply',width:160,align:'center',formatter:formatIsReply">是否回复</th>
                <!--                <th data-options="field:'state',width:80,align:'center',formatter:isHot">状态</th>-->
                <th data-options="field:'_oper',halign:'center',formatter: formatOper">操作</th>
            </tr>
        </thead>
    </table>
</div>

{/block}
{block name="script"}
<script type="text/javascript">

    function formatOper(value, row, index) {
        var html = '<span class="grid-operation">';
        if (row['is_reply']==0) {
            html += '<button type="button" onclick="reply(' + row['id'] + ')" class="btn btn-xs btn-default edit-btn"><i class="icon wb-edit"></i>回复</button>';
        }else{
            html += '';
        }
        
        return html;
    }

    function formatImg(value) {
        var html = '';
        if (value) {
            var html = '<div class="img_box"><a href="' + value + '" target="_blank"><img style="height:35px; margin:5px" src="' + value + '"/></a></div>';

        } 
        return html;
    }
    function img(){
        alert('11');
    }
    function formatType(value) {
        var html = '<span>常见问题</span>';
        if (value==1) {
            var html = '<span>常见问题</span>';
        } else if(value==2){
            var html = '<span>钱包问题</span>';
        }else if(value==3){
            var html = '<span>请求修改</span>';
        }else if(value==4){
            var html = '<span>其他问题</span>';
        }
        return html;
    }


 
    function formatIsReply(value, row, index){
        var text = '<span style="color:green"></span>';
        if(value == 0){
            text = '<span style="color:red">等待回复</span>';
        }
        if(value == 1){
            text = '<span style="color:green">已回复</span>';
        }
        // if(value == 2){
        //     text = '<span style="color:green">用户已解决</span>';
        // }
        // if(value == 3){
        //     text = '<span style="color:barck">用户未解决</span>';
        // }
        return text;
    }

    $(function () {
        $('#grid-table').datagrid({
            url: getURL('loadList'),
            method: "GET",
            height: getGridHeight(),
            rownumbers: true,
            singleSelect: true,
            remoteSort: false,
            multiSort: true,
            emptyMsg: '<span>无相关数据</span>',
            pagination: true,
            pageSize: 20
        });
        //设置分页控件 
        $('#grid-table').datagrid('getPager').pagination({
            pageSize: 20, //每页显示的记录条数，默认为10 
            pageList: [20, 30, 50]
        });
    });

    function reply(id) {
        var url = getURL('reply', 'id=' + id);
        openBarWin('编辑', 1000, 600, url, function () {

                    location.reload();
            
        }, ['保存', '取消']);

    }

    $("#js_search").click(function () {
            reload();
        });
    function reload() {
        var keyword = $("#js_keyword").val();
        $('#grid-table').datagrid('reload', {
            keyword: keyword,
        });
    }
  
</script>
{/block}